package string;

/**
 *
 *
 */
public class StringBuiderDemo {
    public static void main(String[] args) {
        String str = "好好学习java";
        //基于给定字符串创建StringBuider
        //此时StringBuider会将给定字符串内容复制一份到自身char数组中,准备修改
        StringBuilder builder = new StringBuilder(str);
/*      builder.append(",为了找个好工作");
        String s = builder.toString();
        System.out.println(s);
        builder.replace(9,16,"就是为了改变世界");
        System.out.println(builder);

        //删除builder中下标0-8之间的元素
        builder.delete(0,8);
        System.out.println(builder);
        //将"活着"插入到builder最开始的位置
        builder.insert(0,"活着");
        System.out.println(builder);
        //反转字符串
        builder.reverse();
        System.out.println(builder);*/

        builder.append(",为了找个好工作").replace(9,16,"就是为了改变世界").delete(0,8).insert(0,"活着");
        System.out.println(builder);
    }
}
